home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <fcntl.h>
- #include <string.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <signal.h>
-
- /*
- * record.c
- *
- * This program records a song from a CD by using RAP-10 board
- *
- */
-
- #define BUF_SIZE 4096
- #define FILE_HDR "RAP-10 WAVE FILE"
- #define RAP_FILE "/dev/rap"
- #define MAX_BUF 10
-
- uchar_t buf[BUF_SIZE];
- uchar_t *fname;
- int done;
- void endProg( int );
-
- main (int argc, char **argv)
- {
-
- register int fd, rapfd, bytes, i;
-
- if ( argc <= 1 ) {
- printf ("record: Usage: record <file_name>\n");
- exit(0);
- }
-
- fname = argv[1];
- printf ("record: opening file %s\n", fname);
- fd = open (fname, O_WRONLY | O_CREAT, 0777);
- if ( fd == -1 ) {
- printf ("record: Cannot create file, errno = %d\n", errno);
- close(rapfd);
- exit(0);
- }
-
- printf ("record: opening RAP card\n");
- rapfd = open (RAP_FILE, O_RDONLY);
- if ( rapfd <= 0 ) {
- printf ("record: Cannot open RAP card, errno = %d\n",
- errno);
- exit(0);
- }
-
- printf ("record: Writing RAP-10 file ID\n");
- if ( write(fd, FILE_HDR, strlen(FILE_HDR)) <= 0 ) {
- printf ("record: Could not write the file ID, errno = %d\n",
- errno);
- close(rapfd);
- close(fd);
- exit(0);
- }
-
-
- printf ("record: Rcording music ..Ctrl-C to stop\n");
-
- done = 0;
- sigset (SIGINT, endProg);
-
- /* for ( i = 0; i < 10; i++ ) { */
- while ( !done ) {
- bytes = read(rapfd, buf, BUF_SIZE);
- if ( bytes <= 0 ) {
- printf ("record: Cannot read from RAP, errno = %d\n",
- errno);
- close (rapfd);
- close (fd);
- exit(0);
- }
-
- if ( write (fd, buf, bytes) <= 0 ) {
- printf ("record: error writing to file, errno = %d\n",
- errno);
- close (rapfd);
- close (fd);
- exit(0);
- }
- }
-
- printf ("record: Song succesfully recorded\n");
- close(rapfd);
- close (fd);
-
- exit(0);
- }
-
- void
- endProg( int s )
- {
- printf ("record: signal %d received\n", s);
- done = 1;
- }
-
-
-